package com.somnus.designPatterns.strategy;

/** 
 * @Title: MovieTicket.java 
 * @Package com.somnus.designPatterns.strategy 
 * @Description: TODO
 * @author Somnus
 * @date 2015年6月26日 上午9:56:05 
 * @version V1.0 
 */
//电影票类：环境类  
public class MovieTicket {  
  private double price;  
  private Discount discount; //维持一个对抽象折扣类的引用  

  public void setPrice(double price) {  
      this.price = price;  
  }  

  //注入一个折扣类对象  
  public void setDiscount(Discount discount) {  
      this.discount = discount;  
  }  

  public double getPrice() {  
      //调用折扣类的折扣价计算方法  
      return discount.calculate(this.price);  
  }  
}  